import store from '@/store'
import { permissionOpen } from '@/settings'
/**
 * @param {Array} value
 * @returns {Boolean}
 * @example see @/views/permission/directive.vue
 */
// 根据后端标识判断按钮权限
export function checkPermission(value) {
  if (!permissionOpen) return true // 不需要权限校验
  const rolesBtnMenu = store.getters && store.getters.rolesBtnMenu
  if(rolesBtnMenu.indexOf(value) !== -1){
    return true
  } else {
    return false
  }
  // if (value && value instanceof Array && value.length > 0) {
  //   const roles = store.getters && store.getters.roles
  //   const permissionRoles = value
  //   const hasPermission = roles.some(role => {
  //     return permissionRoles.includes(role)
  //   })

  //   if (!hasPermission) {
  //     return false
  //   }
  //   return true
  // } else {
  //   // console.error(`need roles! Like v-permission="['admin','editor']"`)
  //   return false
  // }
}
